<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class default_controller extends base_controller {
    public $default_model ;
    
    public function __construct() {
        $exception = array("");
        $redirectPara = array("module"=>"login",
                              "action"=>"index",
                              "exception"=>$exception);
        parent::__construct('',$session = true ,'uid' ,$redirectPara );
        
        MagicPHP::callMethod()->importLibarary("Magic_Connection_Model");
        MagicPHP::callMethod()->importLibarary("Magic_CRUD_Model");
        MagicPHP::callMethod()->importLibarary("Magic_Common_Model");
        
        $this->default_model = new default_model();
    }
    public function indexController(){
        Template::renderTemplate("header",TEMPLATE_PATH);
        $this->nmessage = $this->default_model->sayHello();
        if(@$_GET["msg"] == '') {
            $this->msg = '';
        } else {
            $this->msg = $_GET["msg"];
        }

    }
    public function printPostArrayController(){
       $f = array("f_name","address","city");
       $d = $_POST ;
        Magic_Connection_Model::callMethod()->connectionOpen();
        if(Magic_CRUD_Model::callMethod()->insertData("employee",$f,$d,0,'','',0,0)) {
            $msg = "Success !";
        } else {
            $msg = "Fail";
        }
        Magic_Connection_Model::callMethod()->connectionClose();
        Magic_Common_Model::callMethod()->_pageRedirect(SITE_URL."default/index?msg=".$msg);
    }
    public function listingController(){
        Magic_Connection_Model::callMethod()->connectionOpen();
        $tableName = 'employee';
        $tableDisplayField = array("f_name","address","city");
        $tableDisplayTitle = array("Name","Address","City");
        $databaseFetchField = array("id","f_name","address","city");
        $pageName =SITE_URL."default/listing";
        MagicPHP::callMethod()->importLibarary("Magic_CreatePagin_Model");
        $pagingArray =array ("dbTableName" => $tableName,
                            "tableDisplayField" => $tableDisplayField,
                            "tableDisplayFieldTitle" =>$tableDisplayTitle,
                            "databaseFetchField" => $databaseFetchField,
                            "pageName"=>$pageName,
                            "extraCondition"=> "",
                            "recordPerPage"=>"2", 
                            "noOfLink"=>"2",
                            "joinStatus"=>0,
                            "queryType"=>0 ,
                            "whereCondition"=> "" ,
                            "leftJoinStatus"=>0,
                            "activeStatus"=>0,
                            "deleteStatus"=>0,
                            "editStatus"=> 0,
                            "primarykeyFieldName"=>"id",
                            "debugQuery"=>0 
                            );
       // $pagingVar = Magic_CreatePagin_Model::callMethoad()->createPaging($pagingArray);
       $pg = new Magic_CreatePagin_Model();
       $this->pagingVar = $pg->searchToolBar($tableDisplayField, $tableDisplayTitle, $value, $interval, $date1, $date2);
       $this->pagingVar .= $pg->createPaging($pagingArray);
       
    }
}
?>
